Telegram Group & Telegram Channel
Команда дня: pipe

Сегодня делимся полезной фишкой из библиотеки pandas — метод .pipe() для создания чистых и читаемых цепочек обработки данных.

import pandas as pd

# Пример: очистка и преобразование данных в одну цепочку
def clean_data(df):
return df.dropna().reset_index(drop=True)

def add_age_group(df):
df['age_group'] = pd.cut(df['age'], bins=[0, 18, 35, 60, 100], labels=['Kid', 'Young', 'Adult', 'Senior'])
return df

# Используем pipe для последовательной обработки
df = (pd.read_csv('data.csv')
.pipe(clean_data)
.pipe(add_age_group))


Зачем это нужно:
🎌 .pipe() позволяет организовать преобразования данных в логическую цепочку, улучшая читаемость кода
🎌 Удобно для сложных ETL-процессов (Extract, Transform, Load)
🎌 Легко добавлять новые шаги обработки

Пример в деле:
def normalize_column(df, col):
df[col] = (df[col] - df[col].mean()) / df[col].std()
return df

df = (pd.DataFrame({'value': [10, 20, 30, 40]})
.pipe(normalize_column, col='value'))


Библиотека дата-сайентиста #буст
Please open Telegram to view this post
VIEW IN TELEGRAM



tg-me.com/dsproglib/6423
Create:
Last Update:

Команда дня: pipe

Сегодня делимся полезной фишкой из библиотеки pandas — метод .pipe() для создания чистых и читаемых цепочек обработки данных.

import pandas as pd

# Пример: очистка и преобразование данных в одну цепочку
def clean_data(df):
return df.dropna().reset_index(drop=True)

def add_age_group(df):
df['age_group'] = pd.cut(df['age'], bins=[0, 18, 35, 60, 100], labels=['Kid', 'Young', 'Adult', 'Senior'])
return df

# Используем pipe для последовательной обработки
df = (pd.read_csv('data.csv')
.pipe(clean_data)
.pipe(add_age_group))


Зачем это нужно:
🎌 .pipe() позволяет организовать преобразования данных в логическую цепочку, улучшая читаемость кода
🎌 Удобно для сложных ETL-процессов (Extract, Transform, Load)
🎌 Легко добавлять новые шаги обработки

Пример в деле:
def normalize_column(df, col):
df[col] = (df[col] - df[col].mean()) / df[col].std()
return df

df = (pd.DataFrame({'value': [10, 20, 30, 40]})
.pipe(normalize_column, col='value'))


Библиотека дата-сайентиста #буст

BY Библиотека дата-сайентиста | Data Science, Machine learning, анализ данных, машинное обучение


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/dsproglib/6423

View MORE
Open in Telegram


Библиотека дата сайентиста | Data Science Machine learning анализ данных машинное обучение Telegram | DID YOU KNOW?

Date: |

Telegram hopes to raise $1bn with a convertible bond private placement

The super secure UAE-based Telegram messenger service, developed by Russian-born software icon Pavel Durov, is looking to raise $1bn through a bond placement to a limited number of investors from Russia, Europe, Asia and the Middle East, the Kommersant daily reported citing unnamed sources on February 18, 2021.The issue reportedly comprises exchange bonds that could be converted into equity in the messaging service that is currently 100% owned by Durov and his brother Nikolai.Kommersant reports that the price of the conversion would be at a 10% discount to a potential IPO should it happen within five years.The minimum bond placement is said to be set at $50mn, but could be lowered to $10mn. Five-year bonds could carry an annual coupon of 7-8%.

Telegram announces Search Filters

With the help of the Search Filters option, users can now filter search results by type. They can do that by using the new tabs: Media, Links, Files and others. Searches can be done based on the particular time period like by typing in the date or even “Yesterday”. If users type in the name of a person, group, channel or bot, an extra filter will be applied to the searches.

Библиотека дата сайентиста | Data Science Machine learning анализ данных машинное обучение from us


Telegram Библиотека дата-сайентиста | Data Science, Machine learning, анализ данных, машинное обучение
FROM USA